package com.zc.center.service;

import com.zc.common.RPCService;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;

import java.util.concurrent.CompletableFuture;

/**
 * Created by stream.
 */
public class MyServiceImpl implements RPCService {

  @Override
  public void asyncService(JsonObject args,String method, Handler<AsyncResult<JsonObject>> handler) {
    JsonObject result=new JsonObject();
    System.out.println("已经调用.....");
    result.put("code",200).put("msg","处理信息，并返回！").put("serviceName",method).put("data",args);
    handler.handle(Future.succeededFuture(result));
  }

  @Override
  public CompletableFuture<JsonObject> futureService(JsonObject args,String method) throws Exception {
    JsonObject result=new JsonObject();
    result.put("code",200).put("msg","处理信息，并返回！").put("serviceName",method).put("data",args);
    System.out.println("CompletableFuture 已经调用.....");
            //throw new Exception("抛一个异常");
    return CompletableFuture.completedFuture(result);
  }
}
